home *** CD-ROM | disk | FTP | other *** search
- // Copyright (C) 1997-2002 Alias|Wavefront,
- // a division of Silicon Graphics Limited.
- //
- // The information in this file is provided for the exclusive use of the
- // licensees of Alias|Wavefront. Such users have the right to use, modify,
- // and incorporate this code into other products for purposes authorized
- // by the Alias|Wavefront license agreement, without fee.
- //
- // ALIAS|WAVEFRONT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- // EVENT SHALL ALIAS|WAVEFRONT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
- // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- // PERFORMANCE OF THIS SOFTWARE.
- //
- //
- // Alias|Wavefront Script File
- // MODIFY THIS AT YOUR OWN RISK
- //
- // Creation Date: 6 May 1997
- // Author: mm
- //
- // Description:
- // This script defines the option box for the NURBS plane menu item.
- //
-
-
- //
- // Procedure Name:
- // setOptionVars
- //
- // Description:
- // Initialize the option values.
- //
- // Input Arguments:
- // Whether to set the options to default values.
- //
- // Return Value:
- // None.
- //
- proc setOptionVars(int $forceFactorySettings)
- {
- if ($forceFactorySettings || !`optionVar -exists nurbsPlanePivotType`) {
- optionVar -intValue nurbsPlanePivotType 1;
- }
-
- if ($forceFactorySettings || !`optionVar -exists nurbsPlanePivotX`) {
- optionVar -floatValue nurbsPlanePivotX 0.0;
- }
- if ($forceFactorySettings || !`optionVar -exists nurbsPlanePivotY`) {
- optionVar -floatValue nurbsPlanePivotY 0.0;
- }
- if ($forceFactorySettings || !`optionVar -exists nurbsPlanePivotZ`) {
- optionVar -floatValue nurbsPlanePivotZ 0.0;
- }
-
-
-
- string $isitYup = `upAxis -q -ax`;
- if( "y" == $isitYup ) {
- if ($forceFactorySettings || !`optionVar -exists nurbsPlaneAxisType`) {
- optionVar -intValue nurbsPlaneAxisType 2;
- }
-
- if ($forceFactorySettings || !`optionVar -exists nurbsPlaneAxisX`) {
- optionVar -floatValue nurbsPlaneAxisX 0.0;
- }
-
- if ($forceFactorySettings || !`optionVar -exists nurbsPlaneAxisY`) {
- optionVar -floatValue nurbsPlaneAxisY 1.0;
- }
- if ($forceFactorySettings || !`optionVar -exists nurbsPlaneAxisZ`) {
- optionVar -floatValue nurbsPlaneAxisZ 0.0;
- }
- }
- else {
- if ($forceFactorySettings || !`optionVar -exists nurbsPlaneAxisType`) {
- optionVar -intValue nurbsPlaneAxisType 3;
- }
-
- if ($forceFactorySettings || !`optionVar -exists nurbsPlaneAxisX`) {
- optionVar -floatValue nurbsPlaneAxisX 0.0;
- }
- if ($forceFactorySettings || !`optionVar -exists nurbsPlaneAxisY`) {
- optionVar -floatValue nurbsPlaneAxisY 0.0;
- }
- if ($forceFactorySettings || !`optionVar -exists nurbsPlaneAxisZ`) {
- optionVar -floatValue nurbsPlaneAxisZ 1.0;
- }
- }
-
-
- if ($forceFactorySettings || !`optionVar -exists nurbsPlaneWidth`) {
- optionVar -floatValue nurbsPlaneWidth 1.0;
- }
- if ($forceFactorySettings || !`optionVar -exists nurbsPlaneLengthRatio`) {
- optionVar -floatValue nurbsPlaneLengthRatio 1.0;
- }
-
-
-
- if ($forceFactorySettings || !`optionVar -exists nurbsPlaneDegree`) {
- optionVar -intValue nurbsPlaneDegree 3;
- }
-
-
-
- if ($forceFactorySettings || !`optionVar -exists nurbsPlanePatchesU`) {
- optionVar -intValue nurbsPlanePatchesU 1;
- }
- if ($forceFactorySettings || !`optionVar -exists nurbsPlanePatchesV`) {
- optionVar -intValue nurbsPlanePatchesV 1;
- }
- }
-
- //
- // Procedure Name:
- // nurbsPlaneSetup
- //
- // Description:
- // Update the state of the option box UI to reflect the option values.
- //
- // Input Arguments:
- // parent - Top level parent layout of the option box UI.
- // Required so that UI object names can be
- // successfully resolved.
- //
- // forceFactorySettings - Whether the option values should be set to
- // default values.
- //
- // Return Value:
- // None.
- //
- global proc nurbsPlaneSetup(string $parent, int $forceFactorySettings)
- {
- // Retrieve the option settings
- //
- setOptionVars($forceFactorySettings);
-
- setParent $parent;
-
- // Query the optionVar's and set the values into the controls.
-
- // Pivot
- //
- int $pivotType = `optionVar -q nurbsPlanePivotType`;
- float $pivotX = `optionVar -q nurbsPlanePivotX`;
- float $pivotY = `optionVar -q nurbsPlanePivotY`;
- float $pivotZ = `optionVar -q nurbsPlanePivotZ`;
- if ($pivotType == 1) {
- $pivotX = 0;
- $pivotY = 0;
- $pivotZ = 0;
- }
- radioButtonGrp -e -select $pivotType nurbsPlanePivotType;
- floatFieldGrp -e
- -v1 $pivotX -v2 $pivotY -v3 $pivotZ
- nurbsPlanePivot;
-
- // Axis
- //
- int $axisType = `optionVar -q nurbsPlaneAxisType`;
- float $axis[3];
- switch($axisType) {
- case 1:
- $axis[0] = 1;
- $axis[1] = 0;
- $axis[2] = 0;
- break;
- case 2:
- $axis[0] = 0;
- $axis[1] = 1;
- $axis[2] = 0;
- break;
- case 3:
- $axis[0] = 0;
- $axis[1] = 0;
- $axis[2] = 1;
- break;
- case 4:
- $axis[0] = `optionVar -q nurbsPlaneAxisX`;
- $axis[1] = `optionVar -q nurbsPlaneAxisY`;
- $axis[2] = `optionVar -q nurbsPlaneAxisZ`;
- break;
- case 5:
- $axis = `nurbsViewDirectionVector 1`;
- break;
- }
- if( $axisType < 4 ) {
- radioButtonGrp -e -select $axisType nurbsPlaneAxisType1;
- }
- else {
- radioButtonGrp -e -select ($axisType - 3) nurbsPlaneAxisType2;
- }
- floatFieldGrp -e
- -v1 $axis[0] -v2 $axis[1] -v3 $axis[2]
- nurbsPlaneAxis;
-
- // Width
- //
- float $planeWidth = `optionVar -q nurbsPlaneWidth`;
- floatSliderGrp -e
- -v $planeWidth
- nurbsPlaneWidth;
-
- // Length Ratio
- //
- float $ratio = `optionVar -q nurbsPlaneLengthRatio`;
- floatSliderGrp -e
- -v `nurbsRatioConvert $planeWidth $ratio false`
- nurbsPlaneLength;
-
- // Degree
- //
- int $degree = `optionVar -q nurbsPlaneDegree`;
- int $degreeBtn;
- switch($degree) {
- case 1: radioButtonGrp -e -select 1 nurbsPlaneDegree123; break;
- case 2: radioButtonGrp -e -select 2 nurbsPlaneDegree123; break;
- case 3: radioButtonGrp -e -select 3 nurbsPlaneDegree123; break;
- case 5: radioButtonGrp -e -select 1 nurbsPlaneDegree57; break;
- case 7: radioButtonGrp -e -select 2 nurbsPlaneDegree57; break;
- default: radioButtonGrp -e -select 3 nurbsPlaneDegree123; break;
- }
-
- // Patches U
- //
- intSliderGrp -e
- -v `optionVar -q nurbsPlanePatchesU`
- nurbsPlanePatchesU;
-
- // Patches V
- //
- intSliderGrp -e
- -v `optionVar -q nurbsPlanePatchesV`
- nurbsPlanePatchesV;
-
- // Disable or enable some controls depending on other values.
- //
- if ($pivotType == 2)
- floatFieldGrp -e -enable 1 nurbsPlanePivot;
- else
- floatFieldGrp -e -enable 0 nurbsPlanePivot;
-
- if ($axisType == 4)
- floatFieldGrp -e -enable 1 nurbsPlaneAxis;
- else
- floatFieldGrp -e -enable 0 nurbsPlaneAxis;
- }
-
- //
- // Procedure Name:
- // nurbsPlaneCallback
- //
- // Description:
- // Update the option values with the current state of the option box UI.
- //
- // Input Arguments:
- // parent - Top level parent layout of the option box UI. Required so
- // that UI object names can be successfully resolved.
- //
- // doIt - Whether the command should execute.
- //
- // Return Value:
- // None.
- //
- global proc nurbsPlaneCallback(string $parent, int $doIt)
- {
- setParent $parent;
-
- // Set the optionVar's from the control values, and then
- // perform the command.
-
- // Pivot
- //
- int $pivotType = `radioButtonGrp -q -select nurbsPlanePivotType`;
- optionVar -intValue nurbsPlanePivotType $pivotType;
- if ($pivotType == 2) {
- optionVar -floatValue nurbsPlanePivotX `floatFieldGrp -q -v1 nurbsPlanePivot`;
- optionVar -floatValue nurbsPlanePivotY `floatFieldGrp -q -v2 nurbsPlanePivot`;
- optionVar -floatValue nurbsPlanePivotZ `floatFieldGrp -q -v3 nurbsPlanePivot`;
- }
-
- // Axis
- //
- int $axisType = `radioButtonGrp -q -select nurbsPlaneAxisType1`;
- if( 0 == $axisType ) {
- $axisType = `radioButtonGrp -q -select nurbsPlaneAxisType2` + 3;
- }
- optionVar -intValue nurbsPlaneAxisType $axisType;
- if( ($axisType == 4) || (5 == $axisType) ) {
- optionVar -floatValue nurbsPlaneAxisX `floatFieldGrp -q -v1 nurbsPlaneAxis`;
- optionVar -floatValue nurbsPlaneAxisY `floatFieldGrp -q -v2 nurbsPlaneAxis`;
- optionVar -floatValue nurbsPlaneAxisZ `floatFieldGrp -q -v3 nurbsPlaneAxis`;
- }
-
- // Width
- //
- float $planeWidth = `floatSliderGrp -q -v nurbsPlaneWidth`;
- optionVar -floatValue nurbsPlaneWidth
- $planeWidth;
-
- // Length Ratio
- //
- float $ratio = `floatSliderGrp -q -v nurbsPlaneLength`;
- optionVar -floatValue nurbsPlaneLengthRatio
- `nurbsRatioConvert $planeWidth $ratio true`;
-
- // Degree
- //
- int $degreeBtn123 = `radioButtonGrp -q -select nurbsPlaneDegree123`;
- int $degreeBtn57 = `radioButtonGrp -q -select nurbsPlaneDegree57`;
- int $degree;
- switch($degreeBtn123) {
- case 1: $degree = 1; break;
- case 2: $degree = 2; break;
- case 3: $degree = 3; break;
- default:
- switch($degreeBtn57) {
- case 1: $degree = 5; break;
- case 2: $degree = 7; break;
- default: $degree = 3; break;
- }
- break;
- }
- optionVar -intValue nurbsPlaneDegree
- $degree;
-
- // Patches U
- //
- optionVar -intValue nurbsPlanePatchesU
- `intSliderGrp -q -v nurbsPlanePatchesU`;
-
- // Patches V
- //
- optionVar -intValue nurbsPlanePatchesV
- `intSliderGrp -q -v nurbsPlanePatchesV`;
-
- if ($doIt) {
- performNurbsPlane 0;
- addToRecentCommandQueue "performNurbsPlane 0" "NURBS Plane";
- }
- }
-
- //
- // Procedure Name:
- // nurbsPlaneOptions
- //
- // Description:
- // Construct the option box UI. Involves accessing the standard option
- // box and customizing the UI accordingly.
- //
- // Input Arguments:
- // None.
- //
- // Return Value:
- // None.
- //
- proc nurbsPlaneOptions()
- {
- // Name of the command for this option box.
- //
- string $commandName = "nurbsPlane";
-
- // Build the option box actions.
- //
- string $callback = ($commandName + "Callback");
- string $setup = ($commandName + "Setup");
-
- // STEP 1: Get the option box.
- // ============================
- //
- // The value returned is the name of the layout to be used as
- // the parent for the option box UI.
- //
- string $layout = getOptionBox();
- setParent $layout;
-
- // STEP 2: Pass the command name to the option box.
- // =================================================
- //
- // Any default option box behaviour based on the command name is set
- // up with this call. For example, updating the 'Help' menu item with
- // the name of the command.
- //
- setOptionBoxCommandName($commandName);
-
- // STEP 3: Activate the default UI template.
- // ==========================================
- //
- // Activate the default UI template so that the layout of this
- // option box is consistent with the layout of the rest of the
- // application.
- //
- setUITemplate -pushTemplate DefaultTemplate;
-
- // Turn on the wait cursor.
- //
- waitCursor -state 1;
-
- // STEP 4: Create option box contents.
- // ===================================
- //
- tabLayout -scr true -tv false;
- string $parent = `columnLayout -adjustableColumn 1`;
-
- radioButtonGrp -label "Pivot"
- -numberOfRadioButtons 2
- -l1 "Object"
- -l2 "User Defined"
- -select 1
- nurbsPlanePivotType;
-
- floatFieldGrp -label "Pivot Point"
- -numberOfFields 3
- nurbsPlanePivot;
-
- radioButtonGrp -label "Axis"
- -numberOfRadioButtons 3
- -l1 "X"
- -l2 "Y"
- -l3 "Z"
- -select 1
- nurbsPlaneAxisType1;
-
- radioButtonGrp
- -numberOfRadioButtons 2
- -l1 "Free"
- -l2 "Active View"
- -scl "nurbsPlaneAxisType1"
- nurbsPlaneAxisType2;
-
- floatFieldGrp -label "Axis Definition"
- -numberOfFields 3
- nurbsPlaneAxis;
-
- separator;
-
- floatSliderGrp -label "Width"
- -fmn 0.0001 -min 0.0001
- -fmx 1000 -max 100
- nurbsPlaneWidth;
-
- floatSliderGrp -label "Length"
- -fmn 0 -min 0
- -fmx 1000 -max 100
- nurbsPlaneLength;
-
- radioButtonGrp -label "Surface Degree"
- -numberOfRadioButtons 3
- -l1 "1 Linear"
- -l2 "2" // Quadratic
- -l3 "3 Cubic"
- -select 3
- nurbsPlaneDegree123;
-
- radioButtonGrp -shareCollection nurbsPlaneDegree123
- -numberOfRadioButtons 2
- -l1 "5" // Quintic
- -l2 "7"
- nurbsPlaneDegree57;
-
- intSliderGrp -l "U Patches"
- -field true
- -min 1
- -fmx 500 -max 100
- nurbsPlanePatchesU;
-
- intSliderGrp -l "V Patches"
- -field true
- -min 1
- -fmx 500 -max 100
- nurbsPlanePatchesV;
-
- // Set the pivot float fields to only be enabled when "Pivot" is "User Defined"
- //
- string $pivotEnable = ("floatFieldGrp -e -en 1 nurbsPlanePivot;"
- + "floatFieldGrp -e"
- + " -v1 `optionVar -q nurbsPlanePivotX`"
- + " -v2 `optionVar -q nurbsPlanePivotY`"
- + " -v3 `optionVar -q nurbsPlanePivotZ`"
- + " nurbsPlanePivot;"
- );
- string $pivotDisable = "floatFieldGrp -e -en 0 nurbsPlanePivot;";
- radioButtonGrp -edit
- -cc1 ($pivotDisable + "floatFieldGrp -e -value 0.0 0.0 0.0 0.0 nurbsPlanePivot;")
- -cc2 $pivotEnable
- nurbsPlanePivotType;
-
- // Set the axis float fields to only be enabled when "Axis Preset" is "Free"
- //
- string $axisEnable = ("floatFieldGrp -e -en 1 nurbsPlaneAxis;"
- + "floatFieldGrp -e"
- + " -v1 `optionVar -q nurbsPlaneAxisX`"
- + " -v2 `optionVar -q nurbsPlaneAxisY`"
- + " -v3 `optionVar -q nurbsPlaneAxisZ`"
- + " nurbsPlaneAxis;"
- );
- string $axisDisable = "floatFieldGrp -e -en 0 nurbsPlaneAxis;";
- radioButtonGrp -edit
- -cc1 ($axisDisable + "floatFieldGrp -e -value 1.0 0.0 0.0 0.0 nurbsPlaneAxis;")
- -cc2 ($axisDisable + "floatFieldGrp -e -value 0.0 1.0 0.0 0.0 nurbsPlaneAxis;")
- -cc3 ($axisDisable + "floatFieldGrp -e -value 0.0 0.0 1.0 0.0 nurbsPlaneAxis;")
- nurbsPlaneAxisType1;
- radioButtonGrp -edit
- -cc1 $axisEnable
- -cc2 $axisDisable
- nurbsPlaneAxisType2;
-
- // Turn off the wait cursor.
- //
- waitCursor -state 0;
-
- // Step 5: Deactivate the default UI template.
- // ===========================================
- //
- setUITemplate -popTemplate;
-
- // Step 6: Customize the buttons.
- // ==============================
- //
- // Provide more descriptive labels for the buttons.
- // Disable those buttons that are not applicable to the option box.
- // Attach actions to those buttons that are applicable to the option box.
-
- // 'Apply' button.
- //
- string $applyBtn = getOptionBoxApplyBtn();
- button -edit
- -label "Create"
- -command ($callback + " " + $parent + " " + 1)
- $applyBtn;
-
- // 'Save' button.
- //
- string $saveBtn = getOptionBoxSaveBtn();
- button -edit
- -command ($callback + " " + $parent + " " + 0 + "; hideOptionBox")
- $saveBtn;
-
- // 'Reset' button.
- //
- string $resetBtn = getOptionBoxResetBtn();
- button -edit
- -command ($setup + " " + $parent + " " + 1)
- $resetBtn;
-
- // Step 7: Set the option box title.
- // =================================
- //
- setOptionBoxTitle("NURBS Plane Options");
-
- // Step 8: Customize the 'Help' menu item text.
- // ============================================
- //
- setOptionBoxHelpTag( "NurbsPlane" );
-
- // Set the current values of the option box.
- // =========================================
- //
- eval (($setup + " " + $parent + " " + 0));
-
- // Show the option box.
- // ====================
- //
- showOptionBox();
- }
-
- //
- // Procedure Name:
- // nurbsPlaneHelp
- //
- // Description:
- // Return a short description about this command.
- //
- // Input Arguments:
- // None.
- //
- // Return Value:
- // string.
- //
- proc string nurbsPlaneHelp()
- {
- return
- " Command: nurbsPlane - create a NURBS plane.\n";
- }
-
- //
- // Procedure Name:
- // assembleCmd
- //
- // Description:
- // Construct the command that will apply the option box values.
- //
- // Input Arguments:
- // None.
- //
- proc string assembleCmd()
- {
- string $cmd = "nurbsPlane";
-
- setOptionVars(false);
-
- int $pivotType = `optionVar -q nurbsPlanePivotType`;
- float $pivotX = `optionVar -q nurbsPlanePivotX`;
- float $pivotY = `optionVar -q nurbsPlanePivotY`;
- float $pivotZ = `optionVar -q nurbsPlanePivotZ`;
- if ($pivotType == 1) {
- $pivotX = 0;
- $pivotY = 0;
- $pivotZ = 0;
- }
-
- // Axis
- //
- int $axisType = `optionVar -q nurbsPlaneAxisType`;
- float $axis[3];
- switch($axisType) {
- case 1:
- $axis[0] = 1;
- $axis[1] = 0;
- $axis[2] = 0;
- break;
- case 2:
- $axis[0] = 0;
- $axis[1] = 1;
- $axis[2] = 0;
- break;
- case 3:
- $axis[0] = 0;
- $axis[1] = 0;
- $axis[2] = 1;
- break;
- case 4:
- $axis[0] = `optionVar -q nurbsPlaneAxisX`;
- $axis[1] = `optionVar -q nurbsPlaneAxisY`;
- $axis[2] = `optionVar -q nurbsPlaneAxisZ`;
- break;
- case 5:
- $axis = `nurbsViewDirectionVector 1`;
- break;
- }
-
- // History
- //
- int $doHistory = `constructionHistory -q -toggle`;
-
- $cmd = ($cmd
- + " -p " + $pivotX + " " + $pivotY + " " + $pivotZ
- + " -ax " + $axis[0] + " " + $axis[1] + " " + $axis[2]
- + " -w " + `optionVar -query nurbsPlaneWidth`
- + " -lr " + `optionVar -query nurbsPlaneLengthRatio`
- + " -d " + `optionVar -query nurbsPlaneDegree`
- + " -u " + `optionVar -query nurbsPlanePatchesU`
- + " -v " + `optionVar -query nurbsPlanePatchesV`
- + " -ch " + $doHistory
- + "; objectMoveCommand");
-
- return $cmd;
- }
-
- //
- // Procedure Name:
- // performNurbsPlane
- //
- // Description:
- // Perform the nurbsPlane command using the corresponding
- // option values. This procedure will also show the option box
- // window if necessary as well as construct the command string
- // that will invoke the nurbsPlane command with the current
- // option box values.
- //
- // Input Arguments:
- // 0 - Execute the command.
- // 1 - Show the option box dialog.
- // 2 - Return the command.
- //
- // Return Value:
- // None.
- //
- global proc string performNurbsPlane(int $action)
- {
- string $cmd = "";
-
- switch ($action) {
-
- // Execute the command.
- //
- case 0:
- // Get the command.
- //
- $cmd = `assembleCmd`;
-
- // Execute the command with the option settings.
- //
- evalEcho($cmd);
-
- break;
-
- // Show the option box.
- //
- case 1:
- nurbsPlaneOptions;
- break;
-
- // Return the command string.
- //
- case 2:
- // Get the command.
- //
- $cmd = `assembleCmd`;
- break;
- }
- return $cmd;
- }
-